<extend name="Include:Layout"/>
<block name="title">评价</block>
<block name="style">
<link rel="stylesheet" href="/Public/Assets/player/plyr.css">
<style>
.btn-edit i {margin-right:10px;}
.weui_tabbar_item {padding-bottom:7px;}
.ygcl_desc {color: #999;font-size: 13px;line-height: 1.2;margin-bottom:8px;}

.star-bar{font-size:0; line-height:0}
.star-bar .star{display:inline-block;text-align:center;}
/*中*/
.size-M img{ width:40px;height:40px}
</style>
</block>

<block name="main">
	<div class="weui_tab">
		<div class="weui_navbar">
			<div class="toolbar">
		        <div class="toolbar-inner">
		            <a href="{:U('home/index/index')}" class="picker-button close-popup">首页</a>
		            <h1 class="title" id="banji_title">老师评价</h1>
		        </div>
		    </div>
		</div>
		<div class="weui_tab_bd container" id="container" style="padding-top:44px;padding-bottom:45px;">
		   		
		   <form>
	  			<div class="weui_cells_title">{$info}</div>
	  			<div class="clearfix" style="width:200px;margin:40px auto;">
					<div id="star-1" class="star-bar size-M f-l mr-10 va-m"></div>
				</div>
			    
		        <div class="weui_cells weui_cells_form">
			        <div class="weui_cell">
			            <div class="weui_cell_bd weui_cell_primary">
			                <textarea class="weui_textarea" id="remark" placeholder="请输入评论" rows="3"></textarea>
			            </div>
			        </div>
			    </div>
			    
			    <div style="padding:15px;">
			    	<input type="hidden" name="cid" value="{$cid}"/>
			    	<input type="hidden" name="teacherid" value="{$teacherid}"/>
			    	<input type="hidden" name="uid" value="{$_SESSION['_loginUser_home']['uid']}"/>
			    	<a href="javascript:;" class="weui_btn weui_btn_primary pinglun">提交评论</a>
			    </div>
			    <div class="weui_cells_title" style="color:#999">注：评价只有校区管理员才能看到</div>
	  		</form>
	  		
	  		<if condition="$pingjia">
	  		<php>$xxpj = C('XINGXING_PINGJIA');</php>
	  		<volist name="pingjia" id="vo">
	  		<div class="weui_panel weui_panel_access">
			  <div class="weui_panel_bd">
			    <div class="weui_media_box weui_media_text">
			      <div class="weui-row">
			      	<div class="weui-col-20"><img src="{$vo.user.headimgurl}" width="100%"/></div>
			      	<div class="weui-col-80">
			      		<h4 class="weui_media_title">{$vo.user.nickname}<span class="ygcl_desc">({$xxpj[$vo[pingjia]]})</span></h4>
			      		<p class="ygcl_desc">{$vo.remark}</p>
			      		<p class="ygcl_desc">{$vo.create_time} <span><a href="javascript:;" class="pjdel" data-pjid="{$vo.id}">删除</a></span></p>
			      	</div>
			      </div>
			    </div>
			  </div>
			</div>
			</volist>
			</if>
		</div>
	</div>
</block>

<block name="script">
<script type="text/javascript" src="/Public/Static/Js/jquery.raty.js"></script>
<script>
$(function(){
	$("#star-1").raty({
		hints: ['1','2', '3', '4', '5'],//自定义分数
		starOff: 'star.png',//默认灰色星星
		starOn: 'star2.png',//黄色星星
		path: '/Public/Static/Img',//可以是相对路径
		number: 5,//星星数量，要和hints数组对应
		showHalf: true,
		targetKeep : true,
		//click:function(score, evt){
			//$("#result-1").html('你的评分是'+score+'分');
		//}
	})
});
$(".pjdel").click(function(){
	var that = $(this);
	var data = {
			id: that.attr("data-pjid"),
	}
	$.post('/api/ygcl/delpingjiateacher',data,function(ret){
		if(ret.status){
			$.toast('已删除','text',function(){
				that.parents(".weui_panel").remove();
			});
		}else{
			$.toast('删除失败','text');
		}
	})
})
$(".pinglun").click(function(){
	var pingjia = $('input[name="score"]').val();
	var remark = $("#remark").val();
	var data = {
			cid:$("input[name=cid]").val(),
			uid:$("input[name=uid]").val(),
			teacherid:$("input[name=teacherid]").val(),
			pingjia:pingjia,
			remark:remark
	}
	$.post('/api/ygcl/saveteaacherpingjia',data,function(ret){
		if(ret.status){
			$.toast('提交成功','text',function(){
				location.reload();
			})
		}
	})
})
</script>
</block>